package com.mtsmda.jpa.domain.manytomanyBidirectional;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

@Entity
@Table(name = "CLASS_ROOMS")
public class ClassRoom {

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "ID_CLASSROOM")
	private Integer idClassRoom;
	private String nameClassRoom;
	private Integer numberClassRoom;

	@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, targetEntity = Teacher.class)
	@JoinTable(name = "ClassRoomS_Teachers", joinColumns = { @JoinColumn(referencedColumnName = "ID_CLASSROOM", name = "ID_CLASSROOM1") }, inverseJoinColumns = { @JoinColumn(referencedColumnName = "ID_TEACHER", name = "ID_TEACHER1") })
	private Set<Teacher> teachers = new HashSet<>();

	public ClassRoom() {
		super();
	}

	public ClassRoom(String nameClassRoom, Integer numberClassRoom) {
		this();
		setNameClassRoom(nameClassRoom);
		setNumberClassRoom(numberClassRoom);

	}

	public Integer getIdClassRoom() {
		return idClassRoom;
	}

	public void setIdClassRoom(Integer idClassRoom) {
		this.idClassRoom = idClassRoom;
	}

	public String getNameClassRoom() {
		return nameClassRoom;
	}

	public void setNameClassRoom(String nameClassRoom) {
		this.nameClassRoom = nameClassRoom;
	}

	public Integer getNumberClassRoom() {
		return numberClassRoom;
	}

	public void setNumberClassRoom(Integer numberClassRoom) {
		this.numberClassRoom = numberClassRoom;
	}

	public Set<Teacher> getTeachers() {
		return teachers;
	}

	public void setTeachers(Set<Teacher> teachers) {
		this.teachers = teachers;
	}

}